//
//  xmcg.m
//  PASystem
//
//  Created by michael on 16/8/24.
//  Copyright © 2016年 czd. All rights reserved.
//

#import "xmcg.h"

@implementation xmcg

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
    UIColor *myColor = [UIColor colorWithWhite:0.8 alpha:0.3];
self.backgroundColor = myColor;


          }
    return self;
}
- (void)setId:(NSString *)id{


//NSLog(@"11%@",id);
_id = id;
[self request];
 
 
}
- (void)request{
NSString * userId = [[NSUserDefaults standardUserDefaults]objectForKey:@"userId"];
    NSString * pwdId = [[NSUserDefaults standardUserDefaults]objectForKey:@"pwdId"];
    NSString * userHumber = [[NSUserDefaults standardUserDefaults]objectForKey:@"userHumber"];
  //1
 NSString *json =[NSString stringWithFormat: @"{'action':xmcgMch,'service':DXMService, 'userName':'%@','password':'%@', 'vaueJson':'{userid :%@,id:%@}'}",userId,pwdId,userHumber,_id];
     NSArray * array = @[@{@"arg0":json}];
    [HttpTools requestWithURL:BaseURL arrays:array method:Basemethod success:^(id JSON) {
    
     NSDictionary *dic = JSON[@"reason"];
//     NSDictionary *dic = [array firstObject];
        NSDictionary *dict = dic[@"attrs"];
       _dic = dict;
    
[self initview];
    }
     failure:^(NSError *error) {
        

    }];


}
- (void)initview{
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(10, 10, KScreenWidth-20, KScreenHeight-64-46-80-20)];
view.backgroundColor= [UIColor whiteColor];

 UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(0,0,KScreenWidth-20 , 20)];
    view1.backgroundColor = [UIColor whiteColor];
    UIView *viewcolor = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, view1.height)];
    viewcolor.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"图标3"]];
    [view1 addSubview:viewcolor];
     UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(viewcolor.right+20, viewcolor.top+5, 200, view1.height-5)];
          label.font = [UIFont systemFontOfSize:13];
label.textColor = [UIColor blueColor];
    label.text = @"项目成果 :";
    [view1 addSubview:label];
[view addSubview:view1];
UIWebView *web = [[UIWebView alloc]initWithFrame:CGRectMake(0, view1.bottom, kScreenWidth-20, view.height-20)];
web.delegate = self;


  NSString *string = _dic[@"SITUATION"];
NSString *result = [string stringByReplacingOccurrencesOfString:@"&quot;" withString:@"\""];

result = [result stringByReplacingOccurrencesOfString:@"&lt;" withString:@"<"];
result = [result stringByReplacingOccurrencesOfString:@"&gt;" withString:@">"];
web.backgroundColor = [UIColor whiteColor];
[web loadHTMLString:result baseURL:nil];
[view addSubview:web];
[self addSubview:view];
}

@end
